<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "{{%option}}".
 *
 * @property string $site_title
 * @property string $site_name
 * @property string $company_name
 * @property string $title_separator
 * @property string site_keywords
 * @property string site_description
 */
class Option extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%option}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['site_title'], 'string', 'max' => 50],
            [['site_name'], 'string', 'max' => 20],
            [['company_name'], 'string', 'max' => 20],
            [['title_separator'], 'string', 'max' => 5],
            [['site_description'], 'string', 'max' => 255],
            [['site_keywords'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'site_title' => 'Site Title',
            'site_name' => 'Site Name',
            'company_name' => 'Company Name',
            'title_separator' => 'Title Separator',
            'site_description' => 'Site Description',
            'site_keywords' => 'Site Keywords',
        ];
    }

    private static function loadModel($id)
    {
        return self::findOne($id);
    }


    public static function getSiteDescription()
    {
        return self::findOne(1)->site_description;
    }

    public static function getSiteKeywords()
    {
        return self::findOne(1)->site_keywords;
    }

    public static function getCompanyName()
    {
        return self::loadModel(1)->company_name;
    }

    public static function getSiteTitle()
    {
        return self::loadModel(1)->site_title;
    }

    public static function getTitleSeparator()
    {
        return self::loadModel(1)->title_separator;
    }

    public static function getSiteTitleWithSeparator()
    {
        return self::getTitleSeparator() . self::getSiteTitle();
    }
}
